package com.hmall.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.item.pojo.Item;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.PathVariable;

public interface ItemMapper extends BaseMapper<Item> {

    //扣减库存
    @Update("update tb_item set stock = stock - #{num} where id = #{itemId}")
    void deductStock(@Param("itemId") Long itemId,
                     @Param("num") Integer num);

    //恢复库存
    @Update("update tb_item set stock = stock + #{num} where id = #{itemId}")
    void restoreStock(@Param("itemId") Long itemId,
                     @Param("num") Integer num);
}
